package net.infoaccelerator.peerReview.model.vo;

import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 * User: andrewpowell
 * Date: Mar 3, 2008
 * Time: 9:03:21 PM
 * To change this template use File | Settings | File Templates.
 */

@Entity
@Table(name = "prDocument")
public class Document implements Serializable {

    private String id;
    private String title;
    private String description;
    private Date submitted;
    private Date accepted;
    private Submitter submittedBy;
    private Reviewer currentReviewer;
    private ArrayList<Review> reviews;

    public Document(String title, String description, Date submitted, Date accepted, Submitter submittedBy, Reviewer currentReviewer) {
        this.title = title;
        this.description = description;
        this.submitted = submitted;
        this.accepted = accepted;
        this.submittedBy = submittedBy;
        this.currentReviewer = currentReviewer;
    }

    public Document() {
    }

    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getSubmitted() {
        return submitted;
    }

    public void setSubmitted(Date submitted) {
        this.submitted = submitted;
    }

    public Date getAccepted() {
        return accepted;
    }

    public void setAccepted(Date accepted) {
        this.accepted = accepted;
    }

    @ManyToOne(cascade = CascadeType.ALL)
    public Submitter getSubmittedBy() {
        return submittedBy;
    }

    public void setSubmittedBy(Submitter submittedBy) {
        this.submittedBy = submittedBy;
    }

    @ManyToOne(cascade = CascadeType.ALL)
    public Reviewer getCurrentReviewer() {
        return currentReviewer;
    }

    public void setCurrentReviewer(Reviewer currentReviewer) {
        this.currentReviewer = currentReviewer;
    }

    @OneToMany(cascade = CascadeType.ALL)
    @JoinTable(name = "pr_documentReviews", joinColumns = @JoinColumn(name = "DOC_ID"), inverseJoinColumns = @JoinColumns(name = "REVIEW_ID"))
    public ArrayList<Review> getReviews() {
        return reviews;
    }

    public void setReviews(ArrayList<Review> reviews) {
        this.reviews = reviews;
    }
}
